package com.renu.jdependencyanalyser.window.action;

import com.renu.jdependencyanalyser.cons.ProjectCons;
import com.renu.jdependencyanalyser.core.ProjectInfo;
import com.renu.jdependencyanalyser.data.ProjectDataCenter;
import com.renu.jdependencyanalyser.freemarker.DependencyProcessor;
import com.renu.jdependencyanalyser.model.ClassModel;
import com.renu.jdependencyanalyser.utils.MyFileUtil;
import com.renu.jdependencyanalyser.utils.MyProjectUtil;
import com.renu.jdependencyanalyser.visualizer.GraphvizVisualizer;
import com.renu.jdependencyanalyser.utils.ImageDialogUtil;

import java.io.File;

public class OuterClsDpndcyPseudoAction  {
      GraphvizVisualizer graphvizVisualizer;
    ProjectInfo projectInfo = ProjectDataCenter.projectInfo;



    ClassModel classModel ;

    public OuterClsDpndcyPseudoAction(String clsSig) {
        this.classModel  = projectInfo.getBorderClassMap().get(clsSig);
        if (classModel == null){
            return ;
        }
        graphvizVisualizer = new GraphvizVisualizer();

        MyFileUtil.createOutDir(MyProjectUtil.projectBasePath + ProjectCons.OUTER_CLASS_INVOKE_DIR);

        String filePath = MyProjectUtil.projectBasePath +ProjectCons.OUTER_CLASS_INVOKE_DIR + File.separator +clsSig + ".png";

        graphvizVisualizer.generateGraph(new DependencyProcessor(projectInfo,classModel,ProjectCons.IN),filePath);

        ImageDialogUtil.showImage(filePath,"查看"+clsSig+"类的依赖图");

    }


}
